package 面向对象编程基础;


class Clock{
    String structure;        // 结构
    String style;            // 样式
    double price;            // 价格
    static String time;      // 时间
    public Clock(String structure, String style, double price){
        this.structure = structure;
        this.style = style;
        this.price = price;
    }
    public void setTime(String time){      // 设置时间
        Clock.time = time;
    }
    public void getTime(){                 //  获取时间
        System.out.println(Clock.time);
    }
}
public class Example4_8 {
    public static void main(String[] args) {
        // 创建Clock类对象watch，并初始化
        Clock watch = new Clock("机械", "表", 1000);
        System.out.println(watch.structure+watch.style+"的价格为: "+watch.price+"元");
        watch.setTime("当前时间: 12:00:00");    // 调用setTime()方法设置时间
        watch.getTime();                      // 调用getTime()方法获取时间
        // 创建Clock类对象clock，并初始化
        Clock clock = new Clock("电子", "闹钟", 12);
        System.out.println(clock.structure+clock.style+"的价格为: "+clock.price+"元");
        clock.setTime("当前时间: 13:00:00");
        clock.getTime();

    }
}
